package com.coderman.infosys.auth.domain.enums;

/**
 * Description:
 * 这里我们从实体 聚合根对象或者业务对象的角度
 * 来构建对象标示枚举方便在必要的时候进行路由
 * date: 2022/1/18
 *
 * @author shenshuai
 * @version 1.0.0
 * @since JDK 1.8
 */
public enum BOIdentiferEnum {
    /**
     *
     */
    SYSTEM("system","系统对象"),
    SYSTEM_AGGREGATE("systemAggregate","系统聚合对象"),
    ROLE("role","角色对象"),
    ROLE_GROUP("roleGroup","角色组对象"),
    USER_GROUP("userGroup","用户组对象"),
    AUTHORITY("authority","权限对象"),
    AUTHORITY_AGGREGATE("authorityAggregate","权限聚合根对象"),

    ;

    /** 权限类型code **/
    private String identifer;
    /** 权限类型描述 **/
    private String desc;


    BOIdentiferEnum(String identifer,String desc){
        this.identifer = identifer;
        this.desc = desc;
    }



    /**
     *
     * @Description:static
     * @return BOIdentiferEnum
     */
    public static BOIdentiferEnum  getByCode(String identifer){
        for (BOIdentiferEnum boIdentiferEnum : BOIdentiferEnum.values()){
            if(boIdentiferEnum.getIdentifer().equals(identifer)){
                return boIdentiferEnum;
            }
        }
        return null;
    }

    public String getIdentifer() {
        return identifer;
    }

    public String getDesc() {
        return desc;
    }

    public static boolean isSystem(String identifer){
        return BOIdentiferEnum.SYSTEM.getIdentifer().equals(identifer);
    }

    public static boolean isSystemAggregate(String identifer){
        return BOIdentiferEnum.SYSTEM_AGGREGATE.getIdentifer().equals(identifer);
    }

    public static boolean isUserGroup(String identifer){
        return BOIdentiferEnum.USER_GROUP.getIdentifer().equals(identifer);
    }


    public static boolean isRole(String identifer){
        return BOIdentiferEnum.ROLE.getIdentifer().equals(identifer);
    }

}
